package net.anzhuo.service.impl;

import lombok.extern.slf4j.Slf4j;
import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.dao.GsAssetsliabMapper;
import net.anzhuo.entity.GsAssetsliab;
import net.anzhuo.service.GsAssetsliabService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
public class GsAssetsliabServiceImpl implements GsAssetsliabService {

	@Autowired
	private GsAssetsliabMapper gsAssetsliabMapper;

	@Override
	public PaginationVO<GsAssetsliab> getListWithPage(GsAssetsliab gsAssetsliab) {
		PaginationVO<GsAssetsliab> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsAssetsliabMapper.getListWithPage(gsAssetsliab));
		paginationVO.setTotalCount(gsAssetsliabMapper.getCount(gsAssetsliab));
		paginationVO.setTotalPage((gsAssetsliabMapper.getCount(gsAssetsliab) + gsAssetsliab.getPageSize() -1)  / gsAssetsliab.getPageSize());
		paginationVO.setPageNo(gsAssetsliab.getPageNo());
		return paginationVO;
	}

	@Override
	public GsAssetsliab getById(Long id) {
		return gsAssetsliabMapper.getById(id);
	}
	
	@Override
	public List<GsAssetsliab> getByYear(String year) {
		return gsAssetsliabMapper.getByYear(year);
	}


	@Override
	public List<GsAssetsliab> getByMd5(String md5) {return gsAssetsliabMapper.getByMd5(md5);}

	@Override
	public List<GsAssetsliab> getList() {
		return gsAssetsliabMapper.getList();
	}

	@Override
	public List<GsAssetsliab> getList(GsAssetsliab gsAssetsliab) {
		return gsAssetsliabMapper.getListByQuery(gsAssetsliab);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsAssetsliab gsAssetsliab) {
		gsAssetsliabMapper.update(gsAssetsliab);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsAssetsliab gsAssetsliab) {
		gsAssetsliabMapper.save(gsAssetsliab);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsAssetsliab gsAssetsliab) {
		gsAssetsliabMapper.delete(gsAssetsliab);
	}
}
